﻿using System.Collections.Generic;

namespace Wizard.Source
{

    public interface IBlockSource
    {
        IStatementSource GetStatement(int index);
        IMethodSource Source { get; set; }
        IStatementSource OwnerStatement { get; set; }
        System.Reflection.FieldInfo StatementFieldInfo { get; set; }
        bool TryGetVariable(string ident, out IBlockVariable variable);
    }
    
    //public class BlockSource
    //{
    //    public readonly StatementSource OwnerStatement;
    //    internal IList<StatementSource> mStatements;
    //    private Dictionary<string, BlockVariable> mVariables;
    //    internal System.Reflection.FieldInfo mStatementFieldInfo;
    //    private string mName;

    //    public IBlockSource(StatementSource ownerStatement)
    //    {
    //        OwnerStatement = ownerStatement;
    //        mStatements = new List<StatementSource>();
    //    }

    //    public StatementSource GetStatement(int index)
    //    {
    //        if (index<0||index>=mStatements.Count) return null;
    //        return mStatements[index];
    //    }

    //    public string Name
    //    {
    //        get
    //        {
    //            return mName;
    //        }
    //    }

    //    internal void SetName(string newName)
    //    {
    //        mName = newName;
    //    }

    //    public virtual IMethodSource Source
    //    {
    //        get { return OwnerStatement.Source; }
    //    }

    //    public int Count
    //    {
    //        get { return mStatements.Count; }
    //    }

    //    public StatementSource AddStatement(string statementType, string statementName)
    //    {
    //        var res = new StatementSource(this, statementType, statementName);
            
    //        mStatements.Add(res);
    //        return res;
    //    }

    //    internal bool TryGetVariable(string varName, out BlockVariable variable)
    //    {
    //        variable = null;
    //        if (mVariables == null) return false;
    //        return mVariables.TryGetValue(varName, out variable);
    //    }

    //    public BlockVariable AddVariable(string variableName, System.Type type)
    //    {
    //        if (mVariables == null) mVariables = new Dictionary<string, BlockVariable>(System.StringComparer.OrdinalIgnoreCase);
    //        var res = new BlockVariable(variableName, type);
    //        mVariables.Add(variableName, res);
    //        return res;
    //    }

    //}

}
